package Clases;

import Clases.Profesor;
import java.awt.Frame;
import javax.swing.JOptionPane;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AsignarProfesor.java
 *
 * Created on 16/02/2011, 10:00:16 AM
 */
/**
 *
 * @author Mariant
 */
public class AsignarProfesor extends javax.swing.JFrame {

    /** Creates new form AsignarProfesor */
    Profesor profe = new Profesor();

    public AsignarProfesor() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        txtnombre = new javax.swing.JTextField();
        txtapellido = new javax.swing.JTextField();
        txtcedula = new javax.swing.JTextField();
        txttitulo = new javax.swing.JTextField();
        btnguardar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setAlwaysOnTop(true);
        getContentPane().setLayout(null);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel1.setText("Datos del Profesor");
        getContentPane().add(jLabel1);
        jLabel1.setBounds(175, 42, 150, 17);

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel2.setText("Nombre");
        getContentPane().add(jLabel2);
        jLabel2.setBounds(50, 100, 90, 14);

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel3.setText("Apellido");
        getContentPane().add(jLabel3);
        jLabel3.setBounds(50, 140, 70, 14);

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel4.setText("Cedula");
        getContentPane().add(jLabel4);
        jLabel4.setBounds(50, 190, 90, 14);

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel5.setText("Titulo Academico");
        getContentPane().add(jLabel5);
        jLabel5.setBounds(50, 240, 100, 14);

        txtnombre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtnombreActionPerformed(evt);
            }
        });
        getContentPane().add(txtnombre);
        txtnombre.setBounds(180, 90, 90, 20);
        getContentPane().add(txtapellido);
        txtapellido.setBounds(180, 140, 90, 20);

        txtcedula.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtcedulaActionPerformed(evt);
            }
        });
        getContentPane().add(txtcedula);
        txtcedula.setBounds(180, 190, 90, 20);
        getContentPane().add(txttitulo);
        txttitulo.setBounds(180, 240, 90, 20);

        btnguardar.setBackground(new java.awt.Color(0, 204, 204));
        btnguardar.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnguardar.setText("Guardar");
        btnguardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnguardarActionPerformed(evt);
            }
        });
        getContentPane().add(btnguardar);
        btnguardar.setBounds(350, 90, 90, 40);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-524)/2, (screenSize.height-350)/2, 524, 350);
    }// </editor-fold>//GEN-END:initComponents

    private void btnguardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnguardarActionPerformed
// TODO add your handling code here:
        if ((txtnombre.getText().isEmpty()) || (txtapellido.getText().isEmpty()) || (txtcedula.getText().isEmpty()) || (txttitulo.getText().isEmpty())) // Mostrar mensaje
        {
            JOptionPane.showMessageDialog(new Frame(), "Campos vacios, verifique", "validacion", JOptionPane.INFORMATION_MESSAGE);
        } else {
            try {
                int x = Integer.parseInt(txtcedula.getText());
                profe.setNombre(txtnombre.getText());
                profe.setApellido(txtapellido.getText());
                profe.setCedula(txtcedula.getText());
                profe.setTituloacademico(txttitulo.getText());
                Menu.setProfe(profe);
                Menu.setVariableProfesor(true);
                dispose();
            } catch (NumberFormatException e) { //y esto valido
                JOptionPane.showMessageDialog(new Frame(), "Error, la cedula debe ser un numero");
            }
        }
    }//GEN-LAST:event_btnguardarActionPerformed

    private void txtnombreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtnombreActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtnombreActionPerformed

    private void txtcedulaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtcedulaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtcedulaActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new AsignarProfesor().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnguardar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JTextField txtapellido;
    private javax.swing.JTextField txtcedula;
    private javax.swing.JTextField txtnombre;
    private javax.swing.JTextField txttitulo;
    // End of variables declaration//GEN-END:variables
}
